﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace CommunicationLibrary
{
    public class Timer
    {
        private DateTime lastTime;

        public void WaitMsFromLast(int msToSleep)
        {
            if (lastTime != null)
            {
                msToSleep -= (DateTime.Now - lastTime).Milliseconds;
                if(msToSleep > 0)
                {
                    Thread.Sleep(msToSleep);
                }
            }
            lastTime = DateTime.Now;
        }
    }
}
